


function login() {
	
	
	
	var uname = $("#uname").val();
	if (uname.length == 0) {
		layer.tips("用户名不能为空!", "#uname", {
			tips: 2,
			time: 1000
		});
		return;
	}
	
	
	
	var upwd = $("#upwd").val();
		if(upwd.length== 0){
			layer.tips("密码不能为空！","#upwd",{
				tips:2,
				time:1000
			});
			return;
		}
		
		
	
	var upwd = $("#upwd").val();
		if(upwd.length<6){
			layer.tips("密码不能少于六位！","#upwd",{
				tips:2,
				time:1000
			});
			return;
		}
		

/*$("#login").click(function(event){
	var uname=$('#uname').val();
	var upwd=$('#upwd').val();
	
	console.log(uname,upwd,vcode);
	
})
*/
		var vcode=$('#vcode').val();
		var patrn=/^[A-Za-z0-9]{4}$/
			if(!patrn.exec(vcode)){
				layer.tips("验证码长度不符合规范！","#vcode",{
					tips:1,
					time:1000
				});
				return;
			}
			if(vcode.toLowerCase()!=code.toLowerCase()){
				layer.tips("输入验证码有误！","#vcode",{
					tips:1,
					time:1000
				});
				return;
			}
			
			
			
		
			
			
			
			
$.ajax({
	url:"dataJSON/login.json",
	type:"get",
	dataType:"json",
	success:function(result){
		var userinfo = result.data;
		var temp = false;
		$.each(userinfo,function(index,value){
		//	alert(JSON.stringify(aa.name))
			if(uname==value.uname&&upwd==value.upwd){
				temp=true;
				return;
			}
		});
		if(temp==false)
			layer.msg("登录失败！",{
				icon:2,
				time:2000
			});
		else{
			var state = $("#rememberPwd").prop("checked");
			if(state==true){
				localStorage.setItem("uname",uname);
				localStorage.setItem("upwd",upwd);
			}else{
				localStorage.clear();
			}
			sessionStorage.setItem("uname",uname);
			location.href="manager.html";
			}
		},
		error: function(){
			layer.msg("请求服务器失败！",{
				icon:2,
				time:2000
			});
		}
	});
	return true;
}
		/*if(result.code==1){
			var state=$("#rememberPwd").prop("checked");
			if(state==true){
				localStorage.setItem("uname",uname);
				localStorage.setItem("upwd",upwd);
			}else{
				localStorage.clear();
			}
			sessionStorage.setItem("uname",uname);
			location.href="manager.html";
		}else
		{
			
		
		layer.msg("登录失败！",{icon:2,time:2000});
		
	}},*/
	/*error:function(){
		layer.msg("请求服务器失败！",{
			icon:2,
			time:2000
		});
	}
	});

}*/